package com.tengju.support.infrastructure.persistence.redis;

import com.tengju.support.domain.model.message.TaskId;
import com.tengju.support.infrastructure.persistence.redis.dataobject.RedisKeyObject;
import com.tengju.support.infrastructure.persistence.redis.dataobject.RedisKeyPrefix;
import org.redisson.api.RLock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class MessageCacheRepository {
    
    @Autowired
    private RedisService redisService;


    /**
     * 获取初始化批次锁
     */
    public RLock getMessageSendLock(TaskId messageId){

        RedisKeyObject redisKeyObject = new RedisKeyObject(RedisKeyPrefix.MESSAGE_SEND,messageId.getValue() + "");

        return redisService.getLock(redisKeyObject);

    }


}
